package com.talkingdata.hadoop.guard.jsonDemo;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

public class FastjsonDemo {
    public static void main(String[] args) {
        readjson4file();
    }
    public static void readjson4file(){
        String json = "{\n" +
                "    \"beans\" : [ {\n" +
                "        \"name\" : \"Hadoop:service=NameNode,name=NameNodeStatus\",\n" +
                "        \"modelerType\" : \"org.apache.hadoop.hdfs.server.namenode.NameNode\",\n" +
                "        \"NNRole\" : \"NameNode\",\n" +
                "        \"HostAndPort\" : \"bj-xg-app-yarn-1001.tendcloud.com:9820\",\n" +
                "        \"SecurityEnabled\" : false,\n" +
                "        \"LastHATransitionTime\" : 0,\n" +
                "        \"BytesWithFutureGenerationStamps\" : 0,\n" +
                "        \"SlowPeersReport\" : null,\n" +
                "        \"SlowDisksReport\" : null,\n" +
                "        \"State\" : \"standby\"\n" +
                "    } ]\n" +
                "}";
        System.out.println(json);
        JSONObject jsonObject = JSONObject.parseObject(json);
        JSONArray beans = jsonObject.getJSONArray("beans");
        String s = beans.get(0).toString();
    }
}
